package view;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

import controller.Controller;

import model.SequenceGen;

/**
 * SequenceGen megjelenítéséért felelős osztály
 * JPanel és MouseListener leszármazás és implementálás a kattinthatóságért
 * @author radioactivebee
 *
 */
public class SequenceGenView extends JPanel implements Paintable, MouseListener, ModelProvider {
	
	private static final long serialVersionUID = 1L;
	private int x;
	private int y;
	private SequenceGen seqGen;
	public OutputView outputView;
	
	public SequenceGenView(int x, int y, SequenceGen seqGen) {
		super();
		this.x = x;
		this.y = y;
		this.seqGen = seqGen;
		outputView = new OutputView(x+70, y+25, seqGen.getOutput(), seqGen);
		setBounds(this.x, this.y, 70, 50);
		addMouseListener(this);
	}
	
	@Override
	public void mouseClicked(MouseEvent e){
		if(Controller.verbose){
			System.out.println("seqgenview mouse listener invoked");		
		}
		Controller.getInstance().seqGenClicked(this);
		Controller.getInstance().blockClicked(this);
	}

	@Override
	public void paint(Graphics g) {
		Image img = new ImageIcon("img/seqgen.png").getImage();
		g.drawImage(img, x, y, null);
		outputView.paint(g);
		
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public SequenceGen getModel(){
		return seqGen;
	}
	
	@Override
	public void mouseEntered(MouseEvent arg0) {
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
	}

	@Override
	public void mousePressed(MouseEvent arg0) {	
	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
	}
}
